package com.yimu.ymblog.admin.controller;

import com.yimu.ymblog.admin.service.AdminUserService;
import com.yimu.ymblog.common.annotation.AccessLimit;
import com.yimu.ymblog.common.aspect.ApiOperationLog;
import com.yimu.ymblog.common.domain.admin.vo.common.SystemHardwareInfoRspVO;
import com.yimu.ymblog.common.domain.admin.vo.user.EmailForgetPasswordReqVO;
import com.yimu.ymblog.common.domain.admin.vo.user.EmailRegisterReqVO;
import com.yimu.ymblog.common.utils.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping("/common")
@Api(tags = "Admin 通用模块")
public class AdminCommonController {

    @Autowired
    private AdminUserService userService;

    @RequestMapping("/sendEmailCode")
    @ApiOperation(value = "发送邮箱验证码", httpMethod = "GET", response = Response.class, notes = "发送邮箱验证码")
    @ApiOperationLog(description = "发送邮箱验证码")
    public Response sendEmailCode(String email, Long type) {
        return userService.sendEmailCode(email, type);
    }

    @AccessLimit
    @RequestMapping(value = "/emailRegister",method = RequestMethod.POST)
    @ApiOperation(value = "邮箱注册", httpMethod = "POST", response = Response.class, notes = "邮箱注册")
    @ApiOperationLog(description = "邮箱注册")
    public Response emailRegister(@Valid @RequestBody EmailRegisterReqVO emailRegisterReqVO){
        return userService.emailRegister(emailRegisterReqVO);
    }

    @AccessLimit
    @RequestMapping(value = "/forgetPassword",method = RequestMethod.PUT)
    @ApiOperation(value = "忘记密码", httpMethod = "PUT", response = Response.class, notes = "忘记密码")
    @ApiOperationLog(description = "忘记密码")
    public Response forgetPassword(@Valid @RequestBody EmailForgetPasswordReqVO emailForgetPasswordReqVO){
        return userService.forgetPassword(emailForgetPasswordReqVO);
    }


}
